//
// Created by vcq on 21/2/9.
//

#pragma once

#include <cstdlib>
#include "api_base.hpp"
#include "model/plan.hpp"
#include "api_user_manager.hpp"
#include "api_finishrequire.hpp"
#include "api_syllabus.hpp"
#include "flow.hpp"
#include "model/_plan_goal.hpp"
#include "model/_require_syllabus.hpp"
#include "api_teachgoal_judge.hpp"
#include "api_finishrequire_goal.hpp"
#include "api_goal.hpp"
#include "profession.hpp"
#include "flow_now.hpp"
#include "require.hpp"
#include "api_require_syllabus.hpp"
#include "teachgoal.hpp"
#include "api_judge.hpp"
#include "grades.hpp"
#include "model/syllabus.hpp"

using namespace nlohmann;

static void getPlanData(request &req, response &res) {
    if (!check_login(req, res)) {
        return;
    }
    basic_string_view<char> id = req.get_query_value("id");
    json item = mgetPlan(id);
    res.set_status_and_content(status_type::ok, item.dump(), req_content_type::json);
}


static void SaveBaseplan(request &req, response &res) {
    if (!check_login(req, res)) {
        return;
    }
    struct plan baseplan{};
    baseplan.id = atoi(req.get_query_value("id").data());
    baseplan.name = req.get_query_value("name");
    baseplan._grade_id = req.get_query_value("_grade_id");
    baseplan._profession_id = req.get_query_value("_profession_id");
    add_plan(baseplan);
    res.set_status_and_content(status_type::ok);
}


static void DeletePlan(request &req, response &res) {
    if (!check_login(req, res)) {
        return;
    }
    MDeletePlan(req.get_query_value("id"));
    res.set_status_and_content(status_type::ok);
}


